<?php

	$title = $_POST['title'];
	$desc = $_POST['description'];
	$deadline = $_POST['deadline'];
	$bid = $_POST['bid'];
   $result = 0;
   
	$filename = stripslashes($_FILES['file']['name']);			   
   $target = "../files/". $filename;
   $targetDB = "files/". $filename;

	//Endrer filnavn hvis det finnes en med det samme navnet
	$i = 0;
	while (is_file($target))
	{
		$i+=1;
		$target = "../files/". $i .$filename;		
		$targetDB = "files/". $i .$filename;//Lagres med denne i databasen
	}

   if(@move_uploaded_file($_FILES['file']['tmp_name'], $target))
      $result = 1;
   else 
   	$targetDB = "";
   	
   
   sleep(1);
   //tit, desc, deadl, b, fileurl
?>

<script language="javascript" type="text/javascript" >window.top.window.newRequest("<?php echo $title; ?>", "<?php echo $desc; ?>", "<?php echo $deadline; ?>", "<?php echo $bid; ?>", "<?php echo $targetDB; ?>");</script>   
